import {Injectable} from '@angular/core';

@Injectable()
export class ImageServeService {
  private APP_ICON_PATH = 'assets/icon/';
  private APP_IMG_PATH = 'assets/images/';

  constructor() {
  }

  getUserIcon(): string {
    return this.APP_ICON_PATH + 'concern_default_head.png';
  }

  getUnfollow(): string {
    return this.APP_IMG_PATH + 'subscript_icon_unfollow.png';
  }

  getIsfollow(): string {
    return this.APP_IMG_PATH + 'subscript_icon_isfollow.png';
  }

  getFollowboth(): string {
    return this.APP_IMG_PATH + 'subscript_icon_isfollowboth.png';
  }

  getPersonalDefault(): string {
    return this.APP_IMG_PATH + 'personal_default_banner.png';
  }

  getAvatarIcon(): string {
    return this.APP_ICON_PATH + 'default_avatar.jpg';
  }

  getSmallArticleImgHolder(): string {
    return this.APP_IMG_PATH + 'placeholder_article_small.png';
  }

  getMiddleArticleImgHolder(): string {
    return this.APP_IMG_PATH + 'placeholder_article_middle.png';
  }

  getLongerArticleImgHolder(): string {
    return this.APP_IMG_PATH + 'placeholder_article_longer.png';
  }

  getLongArticleImgHolder(): string {
    return this.APP_IMG_PATH + 'placeholder_article_long.png';
  }

  getliveAdvUrl(): string {
    return this.APP_IMG_PATH + 'live_adv.png';
  }

  getIconBadgeIcon(type: string) {
    // const imgs = {
    //   'arrowRight': 'icon_more.png'
    // };
    // return type && (this.APP_ICON_PATH + imgs[type]);
    return type && (this.APP_ICON_PATH + (type === 'arrowRight' && 'icon_more.png'));
  }

  /**
   * @description 获取竖形占位图
   * @author ouyqx-691
   * @date 2017/09/21
   */
  getVerticalPlaceholderImg() {
    return this.APP_IMG_PATH + 'placeholder_vertical.png';
  }


  getSignupStateImg(type: string) {
    // const imgs = {
    //   finished: this.APP_ICON_PATH + 'image_finished@3x.png',
    //   full: this.APP_ICON_PATH + 'image_full@3x.png',
    //   processing: this.APP_ICON_PATH + 'image_processing@3x.png',
    //   registration: this.APP_ICON_PATH + 'image_registration@3x.png',
    //   preheating: this.APP_ICON_PATH + 'image_preheating@3x.png',
    // };
    //
    // return type && imgs[type];
    if (type) {
      return this.APP_ICON_PATH + 'image_' + type + '@3x.png';
    }
  }

  getDefaultGraph(type: string) {
    // const imgs = {
    //   train: this.APP_IMG_PATH + 'placeholder_train.png',
    //   noData: this.APP_IMG_PATH + 'image_nodata.png',
    //   competition: this.APP_IMG_PATH + 'competition.png',
    //   recently: this.APP_IMG_PATH + 'recently.png',
    //   notice: this.APP_IMG_PATH + 'notice.png',
    //   unifyPic: this.APP_IMG_PATH + 'missing_unify_pic.png'  // 主站统一缺省图，未配文
    // };
    // return type && imgs[type];
    switch (type) {
      case 'train':
        return this.APP_IMG_PATH + 'placeholder_train.png';
      case 'noData':
        return this.APP_IMG_PATH + 'image_nodata.png';
      case 'competition':
        return this.APP_IMG_PATH + 'competition.png';
      case 'recently':
        return this.APP_IMG_PATH + 'recently.png';
      case 'notice':
        return this.APP_IMG_PATH + 'notice.png';
      case 'unifyPic':
        return this.APP_IMG_PATH + 'missing_unify_pic.png';
    }
  }

  /**
   * 选择的图标
   * @param {string} type
   * @returns
   * @memberof ImageServeService
   */
  getChoseStatus(type: string) {
    // const imgs = {
    //   unselect: this.APP_ICON_PATH + 'event_not_big@2x.png',
    //   selected: this.APP_ICON_PATH + 'event_set_choose@2x.png',
    //   disableSelect: this.APP_ICON_PATH + 'event_choose_already@2x.png',
    // };
    // return type && imgs[type];
    switch (type) {
      case 'unselect':
        return this.APP_ICON_PATH + 'event_not_big@2x.png';
      case 'selected':
        return this.APP_ICON_PATH + 'event_set_choose@2x.png';
      case 'disableSelect':
        return this.APP_ICON_PATH + 'event_choose_already@2x.png';
    }
  }

  /**
   * 头像旁边的性别图标
   * @param {string} type
   * @returns
   * @memberof ImageServeService
   */
  getSexIcon(type: string) {
    // const imgs = {
    //   man: this.APP_ICON_PATH + 'icon_boy.png',
    //   woman: this.APP_ICON_PATH + 'icon_girl.png',
    // };
    // return type && imgs[type];
    switch (type) {
      case 'man':
        return this.APP_ICON_PATH + 'icon_boy.png';
      case 'woman':
        return this.APP_ICON_PATH + 'icon_girl.png';
    }
  }

  getCreatClubImg() {
    return this.APP_IMG_PATH + 'image_organization_add.png';
  }

  getNoDataImg(): string {
    return this.APP_IMG_PATH + 'image_nodata.png';
  }

  /**
   * @description 众筹状态
   * @param {string} type
   * 0,草稿,1,待审核(crowd_pending) 2,审核未通过(crowd_not_pass) 3,众筹中(crowding)，
   * 4，众筹成功(crowd_completed) 5，众筹失败(crowd_defeated),6已下架(crowd_colded_out) 7已禁用 ,
   * @memberof ImageServeService
   */
  getCrowdStateImg(type: string) {
    // const imgs = {
    //   draft: '',
    //   pending: this.APP_ICON_PATH + 'crowd_pending.png',
    //   notPass: this.APP_ICON_PATH + 'crowd_not_pass.png',
    //   crowding: this.APP_ICON_PATH + 'crowding.png',
    //   completed: this.APP_ICON_PATH + 'crowd_completed.png',
    //   defeated: this.APP_ICON_PATH + 'crowd_defeated.png',
    //   coldOut: this.APP_ICON_PATH + 'crowd_colded_out.png'
    // };
    // return type && imgs[type];
    switch (type) {
      case 'pending':
        return this.APP_ICON_PATH + 'crowd_pending.png';
      case 'notPass':
        return this.APP_ICON_PATH + 'crowd_not_pass.png';
      case 'crowding':
        return this.APP_ICON_PATH + 'crowding.png';
      case 'completed':
        return this.APP_ICON_PATH + 'crowd_completed.png';
      case 'defeated':
        return this.APP_ICON_PATH + 'crowd_defeated.png';
      case 'coldOut':
        return this.APP_ICON_PATH + 'crowd_colded_out.png';
      default:
        return '';
    }
  }

  /**
   * @description 优惠券状态标签
   * @param {string} type
   * tag 标签（1：未使用，2：已使用，4：已过期，5：已作废，6：最新，7：将过期）
   * @memberof ImageServeService
   */
  getCouponStateImg(type: string) {
    const imgs = {
      unused: '',
      used: this.APP_IMG_PATH + 'coupon_used.png',
      overdue: this.APP_IMG_PATH + 'coupon_overdue.png',
      invalid: this.APP_IMG_PATH + 'coupon_invalid.png',
      new: this.APP_IMG_PATH + 'coupon_new.png',
      willOverdue: this.APP_IMG_PATH + 'coupon_will_overdue.png',
    };
    return type && imgs[type];
  }


  /**
   * @description 获取图片
   * @author ouyqx-691
   * @date 2017/11/21
   * @param name 图片名字
   */
  getImage(name: string): string {
    return this.APP_IMG_PATH + name;
  }

  /**
   * @description 获取图标
   * @author ouyqx-691
   * @date 2017/11/21
   * @param name 图标名字
   */
  getIcon(name: string): string {
    return this.APP_ICON_PATH + name;
  }

  /**
   * @description 获取图标
   * @author baoww765
   * @date 2017-12-16
   * @param name 图标名字
   */
  getImg(name: string): string {
    return this.APP_IMG_PATH + name;
  }

  getCircle(): string {
    return this.APP_IMG_PATH + 'circle_default.png';
  }

  getSearchIcon() {
    return this.APP_ICON_PATH + 'icon_search@2x.png';
  }
}
